﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace Quản_Lý_Thư_Viện
{
    class ConhieuDataAccess
    {
        private DataProvider _provider = new DataProvider();
        public ConhieuDataAccess()
        {
            _provider.connect();
        }
        public void insertconhieu(ConhieuInfo info)
        {
            string insertCommand = "insert into dbo.CONHIEU(MADAUSACH,MATG) values('" + info.Madausach + "','" + info.Matg + "')";
            _provider.executeNonQuery(insertCommand);
        }
        public DataTable LayTacgia(ConhieuInfo info)
        {
            return _provider.GetData("select TENTG from dbo.CONHIEU,dbo.TACGIA where dbo.CONHIEU.MATG = dbo.TACGIA.MATG and MADAUSACH = '" + info.Madausach + "'");
        }
        public DataTable LayTG()
        {
            return _provider.GetData("SELECT TENTG FROM CONHIEU,TACGIA WHERE TACGIA.MATG = CONHIEU.MATG AND MADAUSACH = '" + frmChinh.mds + "'");
        }
        public void deleteconhieutg(ConhieuInfo info)
        {
            string deleteCommand = "delete from dbo.CONHIEU where MADAUSACH = '" + info.Madausach + "'";
            _provider.executeNonQuery(deleteCommand);
        }
    }
}
